<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 这样写跟那个报错是一模一样的
        // const p1 =new Promise((sesolve,reject)=>{
        //     setTimeout(()=>{
        //         resolve();
        //         reject(
        //             "NavigationDuplicated: Avoided redundant navigation to current location: '/search'."
        //         );
        //     },2000);
        // });

        function push(location,onComplete,onAbort){
            return new Promise((resolve,reject)=>{
                setTimeout(()=>{
                    // resolve();
                    reject(
                        "NavigationDuplicated: Avoided redundant navigation to current location: '/search'."
                    );
                },2000);
            })
            .then(onComplete)
            .catch(onAbort);
        }
        function myPush(a,onComplete = () =>{}, onAbort = () =>{}) {
            return push(a,onComplete,onAbort);
        }
        myPush("123456");
    </script>
</body>
</html>